<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>订单管理</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%-- 引用layui.css --%>
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>js/layui/css/layui.css" />
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>css/common.css" />
</head>
<body>
	<div class="ibox">
		<div class="ibox-content bodycss">
			<!-- 表单搜索 开始 -->
			<section class="panel panel-padding ">
				<form class="layui-form layui-form-pane form-search"
					onsubmit="return false" method="get">
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">会员tvn号</label>
						<div class="layui-input-inline">
							<input name="userId" id="userId" value="" placeholder="请输入会员tvn号"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">会员名称</label>
						<div class="layui-input-inline">
							<input name="userName" id="userName" value="" placeholder="请输入会员名称"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">会员电话</label>
						<div class="layui-input-inline">
							<input name="userPhone" id="userPhone" value=""
								placeholder="请输入会员电话" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<label class="layui-form-label">会员卡号</label>
						<div class="layui-input-inline">
							<div  class="layui-input-inline">
							<input name="userCardNumber" id="userCardNumber" value=""
								placeholder="请输入会员卡号" class="layui-input">
							</div>
						</div>
					</div>
					<div class="layui-form-item layui-inline">
						<button class="layui-btn layui-btn-primary" lay-submit
							lay-filter="seach">
							<i class="layui-icon"></i> 搜索
						</button>
					</div>
				</form>
			</section>
			<!-- 表单搜索 结束 -->
		<section class="panel panel-padding ">
					<!-- pagecontext request session application -->
					
				<table class="layui-table"
					lay-data="{
	                        id: 'menuTeble',
	                        width:'auto',
	                        url:'order/listTvUserCredit.do',
	                        method:'post',
	                        page:true,
	                        even:true,
	                        skin:'row',
	                        limits:[10,20,30,40,50],
	                        limit:10}"
					lay-filter="popedomLay">
					<!-- lay-filter:监听 -->
					<thead>
						<tr>
							<th
								lay-data="{checkbox:true,disabledKey:'check_status',disabledKeyValue:'1,2'}"></th>
							<th lay-data="{type:'numbers', width:50}">序号</th>
							<!-- <th lay-data="{field:'orderId', width:120,align:'center'}">订单id</th> -->
							<th lay-data="{field:'userName', width:150,align:'center'}">会员名称</th>
							<th lay-data="{field:'userPhone', width:150,align:'center'}">会员电话</th>
							<th lay-data="{field:'userId', width:150,align:'center'}">会员tvn号</th>
							<th lay-data="{field:'creditMoney', width:150,align:'center'}">不良金额上限</th>
							<th lay-data="{field:'creditSum', width:150,align:'center'}">不良次数上限</th>
							<th lay-data="{field:'createUserName', width:150,align:'center'}">创建人</th>
							<th lay-data="{field:'userCardNumber', width:150,align:'center'}">会员卡号</th>
							<th lay-data="{field:'createTime', width:150,align:'center'}">创建时间</th>
							<th lay-data="{field:'modifyUserName', width:150,align:'center'}">修改人</th>
							<th lay-data="{field:'modifyTime', width:150align:'center'}">修改时间</th>
							<th lay-data="{field:'remark', width:150,align:'center'}">修改备注</th>
							<th
								lay-data="{fixed: 'right', width:350, align:'center', toolbar: '#popedomBar'}">操作</th>
				
						</tr>
					</thead>
				</table>
			</section>
		</div>
	</div>
	<script type="text/html" id="popedomBar">
			<button class="layui-btn layui-btn-danger layui-btn-xs" lay-event="badCredit">会员不良记录</button>
			<button class="layui-btn layui-bg-cyan layui-btn-xs" lay-event="limitCredit">设置信用限制</button>
    </script>
	<script type="text/javascript" src="<%=basePath%>js/layui/layui.js"></script>
	<script type="text/javascript">
		layui.config({
			base : "<%=basePath%>/js/common/"
		}).use([ "common", "element", "layer", "form", "table", "jquery" ], function() {
			var elem = layui.element;
			var layer = layui.layer;
			var form = layui.form;
			var table = layui.table;
			var $ = layui.jquery;
			layui.common.init();
			/**
			 * 监听刷新表格
			 */
	
			/* 当点击搜索时，执行重载 */
			form.on('submit(seach)', function(data) {
				// layer.msg(JSON.stringify(data.field));
				table.reload('menuTeble', {
					where : data.field,
					page : {
						curr : 1
					}
				});
				return false;
			});
	
			//监听行工具事件
			table.on('tool(popedomLay)', function(obj) {
				var data = obj.data;
				var layEvent = obj.event;
				console.log(data);
				var id = data.orderId;
				console.log(obj.event);
	
				if (layEvent == "badCredit") {
						layer.open({
                    type: 2,
                    title: '查看用户信用详情信息',
                    content: 'order/findCreditDetails.do?creditId='+data.creditId,
                    area: ['750px', '700px'],
                    anim: 5,
                    isOutAnim: true,
                    maxmin: true,
                    resize: false,
                    moveOut: true,
                    zIndex: 99999,
                    success: function(layero, index){
                    	var body = layer.getChildFrame('body', index);
                    },
                    end : function(){
                    	table.reload("menuTeble");
                    }
                });
				} else if (layEvent == "limitCredit") {
					layer.open({
                    type: 2,
                    title: '修改用户信用信息',
                    content: 'order/updateCredit.do?creditId='+data.creditId,
                    area: ['650px', '450px'],
                    anim: 5,
                    isOutAnim: true,
                    maxmin: true,
                    resize: false,
                    moveOut: true,
                    zIndex: 99999,
                    success: function(layero, index){
                    	var body = layer.getChildFrame('body', index);
                    	console.log(body);
                    	  body.contents().find("INPUT[name='userName']").val(data.userName);
                        body.contents().find("INPUT[name='userPhone']").val(data.userPhone);
                        body.contents().find("INPUT[name='creditMoney']").val(data.creditMoney);
                        body.contents().find("INPUT[name='creditSum']").val(data.creditSum);
                        body.contents().find("INPUT[name='createUserName']").val(data.createUserName);
                        body.contents().find("INPUT[name='createTime']").val(data.createTime); 
                    },
                    end : function(){
                    	table.reload("menuTeble");
                    }
                });
				}
			});
	
		});
	</script>
</body>
</html>
